
****************************************************** ANALYSIS FOR "The Impact of Female Role Models on Ph.D. Students’ Prospects for Academic Success", published 2021 in PLOS ONE
****************************************************** BY Shauna Gillooly, Heidi Hardt, and Amy Erica Smith

****************************************************** Analysis by Amy Erica Smith. If you have questions about the analysis or data, please email me: amyericas@gmail.com

use "C:\Users\aesmith2\Dropbox\Work\research in progress\04 Gender Role Models\Data\Quant Survey Data\Public data\Grad_Experiences_Public_v1.dta", clear
cd "C:\Users\aesmith2\Dropbox\Work\research in progress\04 Gender Role Models\Analysis\P1 Impact of Gender Role Models"



****************************************************** data setup
**************** treatment
lab def treatment2 1 "Syllabi with 10% women" 2 "Syllabi with 30% women", modify
	lab val treatment2 treatment2

recode treatment (1 2 = 1) (3 4 = 2), g(treatment3)
	lab def treatment3 1 "All Fake Names" 2 "Partially Fake Names"
	lab val treatment3 treatment3
	
**************** gender
capture drop female
recode q2 (1=1) (2 = 0) (3 4 = .a) (5 = .), g(male)
recode q2 (2=1) (1 = 0) (3 4 = .a) (5 = .), g(female)
	lab def female 0 "Male" 1 "Female" .a "Other/Nonbinary", modify
	lab val female female
recode q2 (1=1) (2=2) (3 4 = 3) (5=.), g(gender)
	lab def gender 1 "Male" 2 "Female" 3 "Other/Nonbinary", modify
	lab val gender gender

**************** DVs
* responses to treatment
foreach var in q12 q14 {
	g `var'r = 6-`var'
}
lab var q12r "Would Enjoy Course"
lab var q14r "Would Succeed in Course"
corr q12r q14r // r only = .35. 

recode q14r (1 2 3 = 0) (4 5 = 1), g(q14r_dichot)

* subjective program success
alpha q28_*, item
egen programsuccess = rowmean(q28_*)
	replace programsuccess = (programsuccess-1)/4

**************** other attitudes
* quantitative methods
alpha q31_1 q31_2
alpha q31_3 q31_4
egen quant = rowmean(q31_1 q31_2)
egen qual = rowmean(q31_3 q31_4)
	lab var quant "Quantitative Orientation"
	lab var qual "Qualitative Orientation"
foreach var in quant qual {
	replace `var' = (`var'-1)/4
}

* Diversity attitudes: note that the battery has 4 items, 2 on gender and 2 on race, and they factor together beautifully. 
* However, given that this paper is only about gender, I'm omitting the two race-based items. The resulting factor is still fine.
pwcorr q32_*
alpha q32_*
alpha q32_1 q32_3
egen diversityattitudes_g = rowmean(q32_1 q32_3)
	replace diversityattitudes = (diversityattitudes-1)/6
	lab var diversityattitudes "Support for Curricular Diversity"

**************** demographics 
g year_in_program = q1
	lab var year_in_program "Year in Program"
recode q3 (21/25=1) (26/29=2) (30/35=3) (36/50=4), g(age)
	lab def age 1 "21-25" 2 "26-29" 3 "30-35" 4 "36-45", modify
	lab val age age
	lab var age "Age in Years"

recode q6 (2=0), g(firstgen)

recode q43_1 (.=0), g(black)
recode q43_2 (.=0), g(latino)
recode q43_3 (.=0), g(white)
	lab def white 0 "Student of Color" 1 "White"
	lab val white white
recode q43_4 (.=0), g(asian)
recode q43_6 (.=0), g(mena)
recode q43_8 (.=0), g(other)
g race = 6 if white == 1
	replace race = 5 if latino == 1
	replace race = 4 if asian == 1
	replace race = 3 if other == 1
	replace race = 2 if black == 1
	replace race = 1 if mena == 1
lab def race 6 "White only" 5 "Latino/a" 2 "Black/African American" 4 "Asian" 1 "Middle Eastern/North African" 3 "Other Race/Ethnicity", modify
	lab val race race
	
recode q26 (2=0), g(haskids)

recode q4 (1 2 5 6 7 = 1) (3 4 = 0), g(haspartner) // Only two people said "other," & they both have partners.

**************** role models
recode q35 (1=0) (2/5=1), g(rolemodel)
egen rolemodelmatch = anycount(q36 q37 q38), values(1)
	recode q36 (1=1) (2 3 = 0), g(rolemodelmatch_gender)
	recode q37 (1=1) (2 3 = 0), g(rolemodelmatch_race)
	recode q38 (1=1) (2 3 = 0), g(rolemodelmatch_other)
g rolemodel_female = rolemodelmatch_gender if female == 1
	replace rolemodel_female = 1-rolemodelmatch_gender if female == 0
	recode rolemodel_female (.=0) if q35 == 1 // code people who say they have no role models as not having female role models
	


*************************************************************************** analysis ********************************************************************************************

********************** Table 1: Demographics
tab1 female year_in_program age firstgen q43_1 q43_2 q43_3 q43_4 q43_5 q43_6 q43_7 q43_8 haskids, mi

********************** Table 2: Summary Statistics for Key Variables
forvalues i = 0/1 {
	summ q14r programsuccess diversityattitudes quant qual if female == `i'
}
	summ q14r programsuccess diversityattitudes quant qual
	mean q14r, over(female)
	
********************** Figure 1: Treatment by gender	
logit q14r_dichot treatment2##female quant qual  
	margins female#treatment2, level(76)
	marginsplot, ciopts(lcolor(gs13)) plot1opts(lcolor(black) mcolor(black) msymbol(D)) plot2opts(lcolor(gs8) mcolor(gs8) lwidth(thick) lpattern(longdash)) ///
		graphregion(fcolor(white) lcolor(black)) ytitle("Predicted Probability of Expecting to Succeed" "in Course (4 or 5 on 1-5 Scale)" "  ") xtitle("Student Gender") ///
		xscale(r(-0.25 1.25)) xlabel(0 "Male" 1 "Female") title("")

********************** Figure 2: Treatment by diversity attitudes
logit q14r_dichot treatment2##c.diversityattitudes female quant qual 
	margins treatment2, at(diversityattitudes=(0(.2)1)) level(84)
	marginsplot, ciopts(lcolor(gs13)) plot1opts(lcolor(black) mcolor(black) msymbol(D)) plot2opts(lcolor(gs8) mcolor(gs8) lwidth(thick) lpattern(longdash)) ///
		graphregion(fcolor(white) lcolor(black)) ytitle("Predicted Probability of Expecting to Succeed" "in Course (4 or 5 on 1-5 Scale)" "  ") title("") ///
		ylabel(.3(.2).9)

********************** Figure 3: Who has a female role model
mean rolemodel_female if q35 > 1, over(female)
logit rolemodel_female female##c.diversityattitudes  
	margins female, at(diversityattitudes=(0(.2)1)) level(84)
	marginsplot, ciopts(lcolor(gs13)) plot1opts(lcolor(black) mcolor(black)) plot2opts(lcolor(gs8) mcolor(gs8) lwidth(thick) lpattern(longdash)) ///
			graphregion(fcolor(white) lcolor(black)) ytitle("Probability of Student Having a" "Female Role Model") ///
			xtitle("Student's Attitudes toward Diversity") title("")

********************** Table 3: Female role model as a determinant of general academic self-efficacy
reg programsuccess i.q35 rolemodel_female##female // + role models

***** gender differences in efficacy?
ttest programsuccess, by(female)
reg programsuccess i.q35##female rolemodel_female // + role models


****************************************************************************** APPENDIX ******************************************************************************************************
***** Table S1: Balance
foreach var in diversityattitudes quant qual female year_in_program age firstgen white haskids {
	ttest `var', by(treatment2)
}

***** Table S2: Correlations with Quant/Qual Orientations
pwcorr female quant qual q14r programsuccess, sig

***** Table S3: Model 1 for Experimental Analysis
ologit q14r treatment2##female quant qual  
	margins treatment2, at(female=0) level(76)
	margins treatment2, at(female=1) level(76)
ologit q14r treatment2##c.diversityattitudes female quant qual 
	margins treatment2, at(diversityattitudes=(0)) level(76) dydx
	margins treatment2, at(diversityattitudes=(1)) level(76)

***** Table S4: Combined Model for Experimental Analysis
reg q14r treatment2##female treatment2##c.diversityattitudes quant qual // battle of the variables: showdown!!!
ologit q14r treatment2##female treatment2##c.diversityattitudes quant qual // battle of the variables: showdown!!!

***** Table S5: Analysis by Full-Versus-Partially Fake Treatment Variable
ttest q14r, by(treatment3)
reg q14r 1.treatment3##female quant qual
reg q14r 1.treatment3##c.diversityattitudes female quant qual

/* ALTERNATIVE: BASICALLY THE SAME PATTERN
reg q14r i.treatment quant qual if female == 0
reg q14r i.treatment quant qual if female == 1
reg q14r i.treatment female quant qual if diversityattitudes <= .5
reg q14r i.treatment female quant qual if diversityattitudes > .5
*/

***** Table S6. Correlates of Having Female Role Models
eststo clear
logit rolemodel_female female diversityattitudes  
	eststo
logit rolemodel_female female##c.diversityattitudes  
	eststo
logit rolemodel_female female##c.diversityattitudes  quant qual female year_in_program age firstgen white haskids 
	eststo
esttab, b(3) se(3) star(^ .10 * .05) nogaps nopar
	

***** Table S7. Correlates of General Academic Self-Efficacy
reg programsuccess i.q35 rolemodel_female##female year_in_program i.age firstgen white haskids quant qual diversityattitudes // + role models


	
